<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1">
<link rel="stylesheet" th:href="@{/css/manage/base.css}">
<link rel="stylesheet" th:href="@{/css/manage/iconfont.css}">
<link rel="stylesheet" th:href="@{/js/lib/zTree_v3/css/zTreeStyle/zTreeStyle.css}">
<link rel="stylesheet" th:href="@{/js/lib/layer/skin/layer.css}">
<title>基础综合管理系统</title>
</head>
<body>
	<div class="wraper" id="wraper">
		<!-- top -->
		<div class="top bi_fn-clear">
			<div class="user-info">
				<shiro:hasPermission name="sysUser:updatePassword"><span class="item-bar" id="updatePass"><i class="iconfont icon-mima1"></i>修改密码</span><span class="hengxian"></span></shiro:hasPermission>
				<span class="item-bar" id="user"> <i class="iconfont icon-guanliyuan"></i><shiro:principal type="com.zhangjianling.premp.entity.sys.SysUser" property="roleName" /></span>
				<span class="hengxian"></span>
				<span class="item-bar" id="exit"><i class="iconfont icon-tuichu"></i>退出</span>
			</div>
			<div class="logo" title="首页">
				基础综合管理系统
			</div>
		</div>
		<!-- left nav -->
		<div class="left-nav" id="left-nav">
			<ul id="menu">
			</ul>
			<span class="qyws_bar bar_left" style="display: none"></span>
		</div>
		<!-- main -->
		<div class="mainCont">
			<div class="main">
				<ul class="bread-dis fn-clear">
					<li><i class="iconfont icon-home base-blue"></i> <span>首页</span> <em>&gt;</em></li>
					<li><span></span> <em>&gt;</em></li>
					<li class="base-blue-01"><span></span></li>
				</ul>
				<div class="data-content"></div>
			</div>
		</div>
	</div>
<div id="user-form" class="data-form" data-title='修改密码'>
	<form id="userForm">
		<table class="base-table form">
			<input type='hidden' name='userId'>
			<tr>
				<td width="150">原密码</td>
				<td><input name="password" id="password" type="password"
					class="base-input validate require">
					<input name="userName" type="hidden"
					class="base-input" value='<shiro:principal/>'>
				</td>
			</tr>
			<tr>
				<td width="150">新密码</td>
				<td><input name="password1" type="password"  id="password1" class="base-input validate require" data-exp="w{2-20}"></td>
			</tr>
		</table>
	</form>
	<div class="toolbar buttom-btn">
			<button id="pass-save" type="button" class="base-btn base-bg-blue">保存</button>
	</div>
</div>
    <script type="text/javascript" th:src="@{/js/lib/jquery/jquery-1.8.3.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/jquery/jquery.form.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/jquery/jquery.setUI.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/zTree_v3/js/jquery.ztree.all.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/handlebars/handlebars.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/layer/layer.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/My97DatePicker/WdatePicker.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/jquery/jquery.nicescroll.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/backstretch/jquery.backstretch.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/ueditor1/ueditor.config.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/ueditor1/ueditor.all.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/validate.js}"></script>
    <script type="text/javascript" th:src="@{/js/BASE.js}"></script>
	<script>
		$(function() {
			//修改密码
			$("#updatePass").click(function(){
				layer.open({
            		  type: 1,
            		  shade: 0.3,
            		  title: "<span class='dialog_title base-zb-info'>"+$("#user-form").data("title")+"</span>",
            		  area: ['400px', '240px'],
            		  content: $('#user-form')
          		});
				$.clear();
			});
			
			$("input[name='password']").on('blur', function() {
				var $_this = $(this);
				if($_this.val()){
					var my = {
							url : "/sysUser/getUser",
                        	type:'get',
							para:{userName:$("#user").data("username"),password:$_this.val()},
							callback : function(res) {
								if(res.code=='2'){
									layer.tips("原密码输入错误", $_this.val(""));
								}
							}
					}
					$._NormalRequest(my);
				}
			});
			
			//保存方法
			$('#pass-save').on('click', function() {
				//表单校验
				var isTemp = $("#userForm").validateForm({
					msgPosition : 'right'
				});
				//分类处理
				if (isTemp) {
					var my = {
							form :"userForm",
							url : "sysUser/updatePassword",
							callback : function(res) {
								if(res.code == '1'){
									$.clear();
									layer.closeAll();
								}
								layer.msg(res.message);
							}
						}
					$._FormRequest(my);
				}
			});
			
			//收缩菜单
			$(".left-nav").on("click",'.super',function(){
				$(this).addClass("base-active").parent('li').siblings()
					   .find('.super').removeClass("base-active")
					   .end().end().end().next()
					   .slideToggle().parent()
					   .siblings().find('.super')
					   .next().slideUp();
			});
			//设置导航
			$(".bread-dis li:eq(1) span").text($(".base-active").attr('title'));

			//退出
			$("body").on("click",'#exit',function(){
				var userId = $(this).data('pkid');
				layer.confirm('你确要退出系统吗？', {
	      		  btn: ['确定','取消']//按钮
	      		}, function(){
					var my = {
							url : "/logout",
                        	type:'get',
							callback : function(res) {
								if(res.code=="1"){
									window.open(window.location.origin+"/login","_self");
								}
								layer.msg(res.message);
							}
					}
					$._NormalRequest(my);
	      		})
			});
			
			//获得菜单列表
			 var menu = {
					url : "/getUserInfo",
                 	type:'get',
					callback : function(res) {
						if(res.code=="1"){
							var menus = res.data.roles[0].memus;
							menus.forEach(function(v,i){
								if(!v.parentMenu){
									var isiframe ="";
									if(v.isiframe !='null' && v.isiframe){
										isiframe = v.isIframe;
									}else{
										isiframe = "";
									}
									if(v.type=='1'){
										var menuHtmls = "<li><a class='super' title="+v.name+" data-isiframe="+isiframe+"><i class='iconfont "+v.icon+"'></i><span>"+v.name+"</span></a><dl>";
										var menu_subhtml = "";
										var menuHtmle = '</dl></li>';
										menus.forEach(function(val,j){
											if(val.isIframe !='null' && val.isIframe !='undefined' && val.isIframe){
												isiframe = val.isIframe;
											}else{
												isiframe = "";
											}
											if(val.parentMenu && val.parentMenu.menuId == v.menuId){
												menu_subhtml += "<dt><a class='sub' title="+val.name+" data-url="+val.url+" data-isiframe="+isiframe+"><i></i>"+val.name+"</a></dt>"
											}
										});
										$("#menu").append(menuHtmls+menu_subhtml+menuHtmle);
									}
								}
							})
							//初始化菜单
							$("#menu").initMenu();
						}
					}
			}
			$._NormalRequest(menu);
		});
	</script>
</body>
</html>
